package com.example.zqathserver.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/idp/oauth2")
public class ZQOAuth2Controller {
    private String clientId = "client_id";
    private String clientSecret = "client_secret";

    @RequestMapping("/getToken")
    public ResponseEntity<Map<String, Object>> getToken() {
        System.out.println("getToken");
        // 组装返回的 JSON 响应
        Map<String, Object> response = new HashMap<>();
        Map<String, Object> stdDataResponse = new HashMap<>();
        Map<String, Object> executionResponse = new HashMap<>();
        Map<String, Object> parameterResponse = new HashMap<>();

        executionResponse.put("code", "0"); // 成功状态码
        parameterResponse.put("accessToken", "accessToken");
        parameterResponse.put("expireIn", "2592000"); // 设置过期时间，单位秒
        parameterResponse.put("userSid", "userSid");
        parameterResponse.put("refreshToken", "refreshToken");

        stdDataResponse.put("execution", executionResponse);
        stdDataResponse.put("parameter", parameterResponse);
        response.put("std_data", stdDataResponse);

        return ResponseEntity.ok(response);
    }

    @RequestMapping("/getUserInfo")
    public ResponseEntity<Map<String, Object>> getUserInfo() {
        System.out.println("getUserInfo");
        // 组装返回的 JSON 响应
        Map<String, Object> response = new HashMap<>();
        Map<String, Object> stdDataResponse = new HashMap<>();
        Map<String, Object> executionResponse = new HashMap<>();
        Map<String, Object> parameterResponse = new HashMap<>();

        executionResponse.put("code", "0"); // 成功状态码
        parameterResponse.put("tenantSid", "tenantSid");
        parameterResponse.put("tenantId", "tenantId");
        parameterResponse.put("userSid", "userSid");
        parameterResponse.put("userId", "userId");
        parameterResponse.put("providerId", "providerId");
        parameterResponse.put("verifyUserId", "hyf");

        stdDataResponse.put("execution", executionResponse);
        stdDataResponse.put("parameter", parameterResponse);
        response.put("std_data", stdDataResponse);

        return ResponseEntity.ok(response);
    }
}


